import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static boolean check(int[] arr,int n){
        int l=0,r=arr.length-1;
        while(l<r){
            int mid=(l+r)/2;
            if(arr[mid]==n){
                return true;
            }
            else if(arr[mid]<n){
                l=mid+1;
            }
            else{
                r=mid-1;
            }
        }
        return false;
    }
    public static void main(String[] args) {
        int[] arr=new int[]{1,7,5,8,10,12,9,6};
        Arrays.sort(arr);
        System.out.println("排序后的数组："+Arrays.toString(arr));
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入你要查找的数字：");
        int n=sc.nextInt();
        if(check(arr,n)){
            System.out.println("找到了！");
        }
        else {
            System.out.println("找不到！");
        }
    }
}
